<?php

class Ajax extends Controller
{
  /*
   * constructor
   */
  function __construct ()
  {
    parent::Controller();
    $this->load->helper('admin');
    $this->load->model('Articles');
  }

  function update_order ()
  {
  	$content = get_content();
  	$order = $_POST['order'];
  	$i = 0;
  	$boxes = explode(';', $order);
  	foreach ($boxes as $b)
  	{
  		if (strlen(trim($b)) > 0)
  		{
	  		$parts = explode('|', $b);
	  		$page = $parts[1];
	  		$c = $content[$page];
	  		$id = $parts[2];
	  		$update_query = $c['update_order'];
	  		
	  		$query = str_replace('@order', $i, $update_query);
	  		$query = str_replace('@id', $id, $query);
	  		
	  		$this->Articles->execute_query($query);
	  		
	  		//echo $b . '<br/>';
	  		echo $query . '<br/>';
	  		//echo '<pre>' . print_r($content[$page], TRUE) . '</pre>';
	  		
	  		$i++;
  		}
  	}
  	//echo print_r($content, TRUE);
  }
  function random_number ()
  {
    sleep(2);
    $order = $_POST['order'];
    $order = explode(';', $order);
    foreach ($order as $o)
    {
    	echo $o . '<br/>';
    }
    
  }
}
?>